package com.yan;

import com.yan.repository.ResumeRepository;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * TODO
 *
 * @Author: 汪焰
 * @Date: 2021/5/28 20:30
 */
@SpringBootApplication
public class MongodbRepositoryMain {

    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(MongodbRepositoryMain.class, args);
//        findAll(applicationContext);
//        findByNameEquals(applicationContext);
        findByNameEqualsAndExpectSalaryEquals(applicationContext);
        findByNameAndExpectSalary(applicationContext);
    }


    private static void findAll(ConfigurableApplicationContext applicationContext) {
        ResumeRepository resumeRepository = applicationContext.getBean(ResumeRepository.class);
        System.out.println("--------------------" + resumeRepository.findAll());
    }

    private static void findByNameEquals(ConfigurableApplicationContext applicationContext) {
        ResumeRepository resumeRepository = applicationContext.getBean(ResumeRepository.class);
        System.out.println("--------------------" + resumeRepository.findByNameEquals("张三"));
    }


    private static void findByNameEqualsAndExpectSalaryEquals(ConfigurableApplicationContext applicationContext) {
        ResumeRepository resumeRepository = applicationContext.getBean(ResumeRepository.class);
        System.out.println("--------------------" + resumeRepository.findByNameEqualsAndExpectSalaryEquals("张三", 18000));
    }

    private static void findByNameAndExpectSalary(ConfigurableApplicationContext applicationContext) {
        ResumeRepository resumeRepository = applicationContext.getBean(ResumeRepository.class);
        System.out.println("--------------------" + resumeRepository.findByNameAndExpectSalary("张三", 18000));
    }


}
